

<!-- 收益列表 -->
<template>
	<view class="container">
		
		<!-- header部分 -->
		<view class='header-Container header-height'>
			<view class="header-bg"></view>
			<navHeader pageTitle="收益列表" rightBtnType="" colorTheme="black" @toggleMenuListHandler="toggleMenuListHandler">
			</navHeader>
		</view>
		
		<!-- 间距条 -->
		<view class="splitLineBar20rpx">
		</view>
		
		
		<!-- 推广明细 -->
		<view v-if="dataList && dataList.length" class="dataList-Container">
			<view v-for="(item, index) of dataList" :key="index" class="dataItem borderOneRpx">
				<view class="headImg">
					<image :src="imgSite + item.headSculpture"></image>
				</view>
				<view class="nameCount">
					<view class="nickName">
						{{item.nickName}}
					</view>
					<view class="newTime">
						{{item.rewardCreateDt | timestampToTime}}
					</view>
				</view>
				<view class="totalPrice-Container">
					<view class="priceMoney">
						{{item.rewardMoney / 100}}
					</view>
					<view class="priceText">
						{{item.rewardName }}
					</view>
				</view>
			</view>
		</view>
		<g-empty v-else></g-empty>
		
		<!-- 详情菜单 -->
		<view v-if="showDetailMenu" @click="toggleMenuListHandler()" class="detailMenu-Container">
			<detailMenu></detailMenu>
		</view>
	</view>
</template>

<script>
	import {
	    mapState,  
	    mapMutations,
	} from 'vuex';  
	
	import navHeader from '@/components/nav-header/nav-header';
	import detailMenu from "@/components/detailMenu/detailMenu";
	
	export default {
		components: {
			navHeader,
			detailMenu
		},
		filters: {
			timestampToTime(timestamp) {
				var date = new Date(timestamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
				var Y = date.getFullYear() + '-';
				var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
				var D = date.getDate() < 10 ?  '0'+date.getDate()+ ' ' : date.getDate()+ ' ';
				var h = date.getHours() < 10 ? '0'+date.getHours()+ ':' : date.getHours()+ ':';
				var m = date.getMinutes() < 10 ? '0'+date.getMinutes()+ ':' : date.getMinutes()+ ':';
				var s = date.getSeconds()< 10 ? '0'+date.getSeconds() : date.getSeconds();
				return Y+M+D+h+m+s;
			}
		},
		data() {
			return {
				icon: {
				},
				
				//详情菜单
				showDetailMenu: false,
				
				dataList: [],
				
				//分页相关
				pageNum: 1,
				pageSize: 10
			};
		},
		computed:{
			...mapState(['imgSite', 'hasLogin'])
		},
		onLoad() {
			this.dataList_fun();
		},
		onShow() {
			this.showDetailMenu = false;
		},
		methods: {
			
			//详情菜单
			toggleMenuListHandler() {
				this.showDetailMenu = !this.showDetailMenu;
			},
			
			
			//推荐列表
			dataList_fun(id) {
				
				var that = this;
				that.$api.globalUtil.requestAjax({
					url: '/CustomerApi/promotionRevenueDetailsApi',
					method: "POST",
					data: {
						pageNum: that.pageNum,  //页码
						pageSize: that.pageSize //显示条数
					},
					success: function(res) {
						if(res.data.success) {
							if(res.data.response.results.length == '0'){
								that.$api.msg("没有更多啦");
							}
							if(that.pageNum-0 == 1){
								that.dataList = res.data.response.results;
							}else{
								for(let i of res.data.response.results){
									that.dataList.push(i);
								}
							}
						}
					}
				});
			}
		},
		onPullDownRefresh() {
			var that = this;
			that.pageNum = 1;
			
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1500);
			
			that.dataList_fun();
		},
		onReachBottom() {
			var that = this;
			that.pageNum = that.pageNum + 1;
			
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1500);
			
			that.dataList_fun();
		}
	}
</script>

<style lang="scss">

	page {
		background: #F5F5F5;
	}
	
	
	/* header部分 */
	.header-Container {
		width: 100%;
		height: 176rpx;
		box-shadow: 0px 1rpx 1rpx 0px rgba(0, 0, 0, 0.08);
		background: rgba(255, 255, 255, 1);
	
		.leftBtns {
			display: flex;
			align-items: center;
			justify-content: flex-start;
			position: absolute;
			bottom: 0;
			width: 100%;
			height: 86rpx;
	
			.back {
				margin-left: 17rpx;
				width: 44rpx;
				height: 44rpx;
			}
		}
	
		.title {
			position: absolute;
			bottom: 0;
			width: 100%;
			height: 86rpx;
			line-height: 86rpx;
			text-align: center;
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: rgba(51, 51, 51, 1);
		}
	}
	
	
	//最新&排序
	.navbar {
		display: flex;
		z-index: 9;
		width: 100%;
		height: 80rpx;
		background: #fff;
		box-shadow: 0 1rpx 5rpx rgba(0,0,0,.06);
		
		.nav-item{
			flex: 1;
			display: flex;
			justify-content: center;
			align-items: center;
			position: relative;
			height: 100%;
			font-size:24rpx;
			font-family:PingFang;
			color:rgba(51,51,51,1);
			
			&.current{
				color: #FE5E49;
			}
		}
		
		
		.p-box {
			display: flex;
			flex-direction: column;
		
			.yticon {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 30upx;
				height: 14upx;
				line-height: 1;
				margin-left: 4upx;
				font-size: 26upx;
				color: #888;
		
				&.active {
					color: $base-color;
				}
			}
		
			.xia {
				transform: scaleY(-1);
			}
		}
	}
	
	
	//分割条
	.splitLineBar20rpx {
		z-index: 9;
		// position: fixed;
		// top: 256rpx;
		width: 100%;
		height: 20rpx;
		background: #F5F5F5;
	}
	
	
	//推广列表
	.dataList-Container {
		width: 100%;
		background:rgba(255,255,255,1);
		border-radius:16rpx;
		
		.dataItem {
			position: relative;
			display: flex;
			align-items: center;
			margin: 0 auto;
			width: 690rpx;
			height: 140rpx;
			
			&.borderOneRpx:after {
				border-top: 0;
				border-left: 0;
				border-right: 0;
				border-color: #EEEEEE;
			}
			
			.headImg {
				width: 80rpx;
				height: 80rpx;
				
				image {
					width: 100%;
					height: 100%;
				}
			}
			
			.nameCount {
				display: flex;
				flex-direction: column;
				margin-left: 28rpx;
				width: 300rpx;
				
				.nickName {
					font-size:28rpx;
					font-family:PingFang SC;
					// font-weight:500;
					color:rgba(51,51,51,1);
				}
				
				.count {
					font-size:24rpx;
					font-family:PingFang SC;
					// font-weight:500;
					color:rgba(102,102,102,1);
					
					span {
						color: #FE5E49;
					}
				}
				
				.newTime {
					font-size:24rpx;
					font-family:PingFang SC;
					// font-weight:500;
					color:rgba(191,191,191,1);
				}
			}
			
			
			.totalPrice-Container {
				display: flex;
				flex-direction: column;
				justify-content: center;
				margin-left: auto;
				
				.priceMoney {
					text-align: right;
					font-size:36rpx;
					font-family:PingFang SC;
					// font-weight:bold;
					color:rgba(51,51,51,1);
				}
				
				.priceText {
					text-align: right;
					font-size:24rpx;
					font-family:PingFang SC;
					// font-weight:500;
					color:rgba(153,153,153,1);
				}
			}
		}
	}
</style>



